package com.stars.controller.system;

import com.stars.common.annotation.Log;
import com.stars.common.annotation.UserMenuUpdateRedis;
import com.stars.common.base.BaseConstant;
import com.stars.common.base.BaseMsg;
import com.stars.common.base.ResultMsg;
import com.stars.common.enums.OperationType;
import com.stars.controller.BaseController;
import com.stars.services.system.SystemPerOrgConfigServices;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @Title: 资源与组织关系 mybatis dao
 * @author dj
 * @date 2019-10-17 20:57:37
 * @version V1.0
 *
 */
@Slf4j
@RestController
@RequestMapping("/systemPerOrgCtl")
@Api(tags ="资源与组织关系")
public class SystemPerOrgCtl extends BaseController{
   @Autowired
   private SystemPerOrgConfigServices  systemPerOrgConfigServicesImpl;

    /**
    * 保存
    * @param ids 菜单集合
    * @return 成功失败
    * @throws Exception
    */
    @PostMapping(value = "/add")
    @ApiOperation(value = "资源与组织关系"+ BaseMsg.MODULAR_ADD,notes = "资源与组织关系"+BaseMsg.MODULAR_ADD)
    @Log(detail = "资源与组织关系"+BaseMsg.MODULAR_ADD,operationType = OperationType.INSERT)
    @UserMenuUpdateRedis(permission = true)
    public ResultMsg addSystemPerOrg(String ids,String orgIds) throws Exception{
        String [] idList = ids.split(BaseConstant.SPOT);
        String [] orgList = orgIds.split(BaseConstant.SPOT);
        return systemPerOrgConfigServicesImpl.addPerOrg(orgList,idList);
    }
    /**
    * 更新
    * @param ids
    * @return 成功失败
    * @throws Exception
    */
    @PostMapping(value = "/update")
    @ApiOperation(value = "资源与组织关系"+ BaseMsg.MODULAR_UPDATE,notes = "资源与组织关系"+ BaseMsg.MODULAR_ADD)
    @Log(detail = "资源与组织关系"+ BaseMsg.MODULAR_UPDATE,operationType = OperationType.UPDATE)
    @UserMenuUpdateRedis(permission = true)
    public ResultMsg updateSystemPerOrg(String ids,String orgIds) throws Exception{
        String [] idList = ids.split(BaseConstant.SPOT);
        String [] orgList = orgIds.split(BaseConstant.SPOT);
        return systemPerOrgConfigServicesImpl.delPerOrg(orgList,idList);
    }



}